/**
 * @author : cyb1010
 * @date   : 2024-06-13 10:22:43
 * @file   : grid.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) int(v.size())
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
void ckmx(int &x, int y) { x < y && (x = y); }
void ckmn(int &x, int y) { x > y && (x = y); }
const int N = 500010;
int __, n, m, k, f[N];
struct rec {
    int l, r, u, d;
} a[N];
set<pair<int, int>> U[2][N << 2];
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
void ins(int p, int l, int r, int x) {
    if (l > a[x].r || r < a[x].l) return;
    U[0][p].emplace(a[x].u, x);
    if (l >= a[x].l && r <= a[x].r) return U[1][p].emplace(a[x].u, x), void();
    int mid = l + r >> 1;
    ins(p << 1, l, mid, x), ins(p << 1 | 1, mid + 1, r, x);
}
void del(int p, int l, int r, int x) {
    if (l > a[x].r || r < a[x].l) return;
    U[0][p].erase({a[x].u, x});
    if (l >= a[x].l && r <= a[x].r) return U[1][p].erase({a[x].u, x}), void();
    int mid = l + r >> 1;
    del(p << 1, l, mid, x), del(p << 1 | 1, mid + 1, r, x);
}
int qry(int p, int l, int r, int le, int ri, int dw, int up) {
    if (l > ri || r < le) return 0;
    auto it = U[1][p].lower_bound({dw, 0});
    if (it != U[1][p].end() && a[it->se].d <= up) return it->se;
    if (l >= le && r <= ri) {
        it = U[0][p].lower_bound({dw, 0});
        if (it != U[0][p].end() && a[it->se].d <= up) return it->se;
        return 0;
    }
    int mid = l + r >> 1, x = qry(p << 1, l, mid, le, ri, dw, up);
    return x ? x : qry(p << 1 | 1, mid + 1, r, le, ri, dw, up);
}
int main() {
    fo("grid");
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= k; i++) {
        cin >> a[i].u >> a[i].l;
        a[i].r = a[i].l, a[i].d = a[i].u, f[i] = i;
        // cin >> a[i].l >> a[i].r >> a[i].d >> a[i].u, f[i] = i;
        while (true) {
            int x = qry(1, 1, m, a[i].l, a[i].r, a[i].d - 2, a[i].u + 2);
            if (!x) x = qry(1, 1, m, a[i].l - 2, a[i].r + 2, a[i].d, a[i].u);
            if (!x)
                x = qry(1, 1, m, a[i].l - 1, a[i].r + 1, a[i].d - 1,
                        a[i].u + 1);
            if (!x) break;
            del(1, 1, m, x), f[x] = i;
            ckmn(a[i].l, a[x].l), ckmn(a[i].d, a[x].d);
            ckmx(a[i].r, a[x].r), ckmx(a[i].u, a[x].u);
        }
        ins(1, 1, m, i);
    }
    ll ans = 0;
    for (int i = 1; i <= k; i++)
        if (f[i] == i) {
            ans += ll(a[i].u - a[i].d + 1) * (a[i].r - a[i].l + 1);
            // cerr << a[i].l << ' ' << a[i].r << ' ' << a[i].d << ' ' << a[i].u
            //      << endl;
        }
    cout << ans << '\n';
    return 0 ^ __ ^ 0;
}

/*
*/